using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class JobSeekers_experience : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session.Contents["jsuserid"] == null)
        {
            Response.Redirect("login.aspx");
        }
        else
        {
            string experienceID = Request.QueryString.Get("ExperienceID");
            if (!IsPostBack)
                EditExperience(experienceID);
        }
    }
    void EditExperience(string experienceID)
    {
        if (experienceID != "" && experienceID != null)
        {
            SQLServerProviders cls = new SQLServerProviders();
            DataTable dataTable =
            cls.GetDataTable("select * from tblJSExperiences" +
            " where UserID='" + Session["jsuserid"] +
             "' and ExperienceID='" + experienceID
             + "'", CommandType.Text);
            ExperienceID.Value = dataTable.Rows[0][0].ToString();
            txtCompany.Text = dataTable.Rows[0][2].ToString();
            txtAddress.Text = dataTable.Rows[0][3].ToString();
            ddlCountry.SelectedValue = dataTable.Rows[0][4].ToString();
            ddlDepartment.SelectedValue = dataTable.Rows[0][5].ToString();
            txtPosition.Text = dataTable.Rows[0][6].ToString();          
            txtFrom.Text = dataTable.Rows[0][7].ToString();
            txtTo.Text = dataTable.Rows[0][8].ToString();
            txtSalary.Text = dataTable.Rows[0][9].ToString();
            txtSummary.Text = dataTable.Rows[0][10].ToString();            
            txtDescription.Text = dataTable.Rows[0][11].ToString();
        }
    }
    protected void btnNext_Click(object sender, EventArgs e)
    {        
            Response.Redirect("skills.aspx");
        
    }
    protected void btnMore_Click(object sender, EventArgs e)
    {
        SQLServerProviders cls = new SQLServerProviders();
        if (!cls.AddNewUpdateExperience("0",
        Convert.ToString(Session.Contents["jsuserid"]),
        txtCompany.Text, txtAddress.Text,
        ddlCountry.SelectedValue,
        ddlDepartment.SelectedValue,
        txtSummary.Text,
        txtPosition.Text,
        txtFrom.Text, txtTo.Text,
        txtSalary.Text,
        txtDescription.Text))
            literalError.Text = "Error: " + cls.ErrorMessage;
        else
            
            if (ExperienceID.Value != "")
                Response.Redirect("experiences.aspx");
            else
                Response.Redirect("skills.aspx");
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string id="0";
        if (ExperienceID.Value != "")
            id=ExperienceID.Value;
        SQLServerProviders cls = new SQLServerProviders();
        if (!cls.AddNewUpdateExperience(id,
        Convert.ToString(Session.Contents["jsuserid"]),
        txtCompany.Text, txtAddress.Text,
        ddlCountry.SelectedValue,
        ddlDepartment.SelectedValue,
        txtSummary.Text,
        txtPosition.Text,
        txtFrom.Text, txtTo.Text,
        txtSalary.Text,
        txtDescription.Text))
            literalError.Text = "Error: " + cls.ErrorMessage;
        else
            if (ExperienceID.Value != "")
                Response.Redirect("experiences.aspx");
            else
                Response.Redirect("skills.aspx");
    }
}
